package cjakma.study.portfolio.pofol.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cjakma.study.portfolio.common.controller.BaseController;
import cjakma.study.portfolio.pofol.service.PortfolioService;
import cjakma.study.portfolio.pofol.vo.RequestVO;

@Controller
@RequestMapping("/web")
public class PofolController extends BaseController implements MessageSourceAware {
	
	private static final long serialVersionUID = -7453606094644144082L;
	private Logger log = LoggerFactory.getLogger(this.getClass());
	private MessageSource messageSource;
	
	@Override
	public void setMessageSource(MessageSource arg0) {
		this.messageSource = messageSource;
	}
	
	@Autowired
	private PortfolioService portfolioService;
	
	
	/**
	 * Web main page
	 * GET - getWebMain : {context}/getWebMain
	 * @param vo
	 * @return successYn
	 * @throws Exception
	 */
	@RequestMapping(method = RequestMethod.GET, value = "/getWebMain")
	public ModelAndView getWMain (RequestVO request, BindingResult result, Model model) throws Exception {
		ModelAndView mav = new ModelAndView();

		model.asMap().clear();
		mav.clear();
		//ResponseVO resV = new ResponseVO();
		
		// logging API name
		log.debug("/getMain API Start");
		
		ServletContext context = getRequest().getSession().getServletContext();
		System.out.println("ServletContext : " + context.getContextPath());
		model.addAttribute("defaultContext", context.getContextPath());
		
		return new ModelAndView ("wmain"); 
	}
	
}